package com.yinp.proapp.module.game.fourcolormap;

import android.graphics.Color;

import java.util.List;

/**
 * @author :yinpeng
 * date      :2021/9/16
 * package   :com.yinp.proapp.module.game.fourcolormap
 * describe  :
 */
public class FCM_judge {
    /**
     * @param provinceItemList
     * @param position
     * @param curColor
     * @return 返回false表示无相邻
     */
    public static boolean judge(List<ProvinceItem> provinceItemList, int position, int curColor) {
        if (curColor == Color.WHITE) {
            return false;
        }
        switch (position) {
            case 30://新疆
                return isThem(curColor, provinceItemList, 31, 22, 5);
            case 31://西藏
                return isThem(curColor, provinceItemList, 30, 22, 24, 32);
            case 22://青海
                return isThem(curColor, provinceItemList, 30, 31, 5, 24);
            case 5://甘肃
                return isThem(curColor, provinceItemList, 30, 22, 24, 20, 21, 23);
            case 24://四川
                return isThem(curColor, provinceItemList, 31, 22, 5, 23, 2, 32, 7);
            case 32://云南
                return isThem(curColor, provinceItemList, 31, 24, 7, 6);
            case 20://内蒙古
                return isThem(curColor, provinceItemList, 5, 21, 23, 27, 9, 18, 15, 12);
            case 21://宁夏
                return isThem(curColor, provinceItemList, 20, 5, 23);
            case 23://陕西
                return isThem(curColor, provinceItemList, 21, 5, 2, 24, 20, 27, 10, 14);
            case 2://重庆
                return isThem(curColor, provinceItemList, 23, 24, 7, 14, 13);
            case 7://贵州
                return isThem(curColor, provinceItemList, 2, 24, 32, 13, 6);
            case 6://广西
                return isThem(curColor, provinceItemList, 32, 7, 13, 4);
            case 27://山西
                return isThem(curColor, provinceItemList, 20, 23, 10, 9);
            case 9://河北
                return isThem(curColor, provinceItemList, 27, 20, 10, 18, 25, 28, 1);
            case 18://辽宁
                return isThem(curColor, provinceItemList, 9, 15, 20);
            case 15://吉林
                return isThem(curColor, provinceItemList, 12, 18, 20);
            case 12://黑龙江
                return isThem(curColor, provinceItemList, 15, 20);
            case 10://河南
                return isThem(curColor, provinceItemList, 9, 27, 23, 14, 25, 0);
            case 14://湖北
                return isThem(curColor, provinceItemList, 2, 23, 10, 13, 0, 17);
            case 13://湖南
                return isThem(curColor, provinceItemList, 14, 2, 7, 4, 17, 6);
            case 4://广东
                return isThem(curColor, provinceItemList, 6, 13, 17, 3, 8);
            case 25://山东
                return isThem(curColor, provinceItemList, 10, 9, 0, 16);
            case 28://天津
                return isThem(curColor, provinceItemList, 1, 9);
            case 1://北京
                return isThem(curColor, provinceItemList, 28, 9);
            case 17://江西
                return isThem(curColor, provinceItemList, 0, 13, 14, 33, 4, 3);
            case 0://安徽
                return isThem(curColor, provinceItemList, 14, 10, 25, 33, 17, 16);
            case 16://江苏
                return isThem(curColor, provinceItemList, 25, 0, 33, 26);
            case 3://福建
                return isThem(curColor, provinceItemList, 33, 17, 4);
            case 33://浙江
                return isThem(curColor, provinceItemList, 3, 26, 17, 0, 16);
            case 26://上海
                return isThem(curColor, provinceItemList, 33, 16);
            case 8://海南
                return isThem(curColor, provinceItemList, 4);
            case 29://台湾
                return false;
            case 11://香港
                return false;
            case 19://澳门
                return false;
        }
        return false;
    }

    private static boolean isThem(int curColor, List<ProvinceItem> provinceItemList, int... positions) {
        for (int i = 0; i < positions.length; i++) {
            if (provinceItemList.get(positions[i]).selectColor == curColor) {
                return true;
            }
        }
        return false;
    }
}
